#pragma once


// Copyright (c) 2010 Manuel Peinado Gallego <manuel.peinado@gmail.com>
// Distributed under the MIT license

// CWorldBuilderApp.h : interface of the CWorldBuilderApp class
//

#ifndef __AFXWIN_H__
    #error "include 'stdafx.h' before including this file for PCH"
#endif

#include "resource.h"       // main symbols
#include "World.h"
#include "Ui.h"
#include "Common.h"
#include "ActionManager.h"



class CWorldBuilderApp : public CWinAppEx
{
public:
    CWorldBuilderApp();
    ~CWorldBuilderApp();

    class CMainFrame * getMainFrame() const;
    class CMainView * getActiveView() const;

    // Like "activeView" but returns non-NULL even if the 
    // main view is not active (i.e., doesn't have focus)
    CMainView * getMainView() const;

    class CWorldBuilderDoc * getActiveDocument() const;
    class CPropertiesWnd * getPropertiesWnd() const;
    class CSceneTreeCtrl * getSceneTreeCtrl() const;
    class COutputWnd * getOutputWnd() const;

    double getTimeMicro() const;

    World& getWorld() { return m_world; }
    Ui& getUi() { return m_ui; }


// Overrides
protected:

    World m_world;
    Ui m_ui;

public:

    virtual BOOL InitInstance();

    // Implementation
    UINT  m_nAppLook;
    BOOL  m_bHiColorIcons;

    // For scintilla edit control
    HINSTANCE m_hSciDLL;

    virtual void PreLoadState();
    virtual void LoadCustomState();
    virtual void SaveCustomState();

    afx_msg void OnAppAbout();
    DECLARE_MESSAGE_MAP()
    virtual BOOL OnIdle(LONG lCount);

protected:
    void LoadStdProfileSettingsEx(UINT nMaxMRU);

    __int64 m_lastCounter;
    double m_FreqMicroSecs;
    bool m_lastTickReady;
public:
    virtual int ExitInstance();
};

extern CWorldBuilderApp theApp;
extern View3d* theView;